package com.example.uit_management;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ArrayAdapterSchedule extends BaseAdapter {
	// XML node keys
    private Activity activity;
    private ArrayList<HashMap<String, String>> data;
    private static LayoutInflater inflater=null;   
    
    public ArrayAdapterSchedule(Activity a, ArrayList<HashMap<String, String>> d) {    	
        activity = a;        
        data=d;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }   
    public int getCount() {
        return data.size();
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }
    
    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        if(convertView==null)
            vi = inflater.inflate(R.layout.schedule_row, null);

        TextView time_schedule = (TextView)vi.findViewById(R.id.time_schedule); 
        TextView subjectName_schedule = (TextView)vi.findViewById(R.id.subjectName_schedule); 
        TextView RoomID_schedule = (TextView)vi.findViewById(R.id.RoomID_schedule); 
        TextView lecturerName_schedule = (TextView)vi.findViewById(R.id.lecturerName_schedule); 
        TextView coursetime_shedule = (TextView)vi.findViewById(R.id.coursetime_shedule); 
       
       
        
        HashMap<String, String> array = new HashMap<String, String>();
        array = data.get(position);
        String a= "Bao cao :"+ position;
        //Log.e(ArrayAdapterSchedule.class.toString(), a);
        // Setting all values in listview
        time_schedule.setText("Thứ :"+array.get(JsonParser_course.KEY_courseDay));
        subjectName_schedule.setText(array.get(JsonParser_course.KEY_subjectName)+"_"+array.get(JsonParser_course.KEY_courseID));
        RoomID_schedule.setText("Phòng :"+array.get(JsonParser_course.KEY_roomID));
        lecturerName_schedule.setText("Giáo Viên :"+ array.get(JsonParser_course.KEY_lecturerName));
        coursetime_shedule.setText("Ca"+array.get(JsonParser_course.KEY_courseTime));
      
        return vi;
    }
}